<?php
use yii\helpers\Url;
use common\models\WxPublic\WxPublic;
?>
<?php $this->beginBlock('content') ?>
<div class="row">
   <div class="col-sm-12">
        <div class="white-box">
            <h3 class="box-title"></h3>
            <div class="row m-b-15">
                <div class="col-sm-10">
                    <form action="">
                        <div class="row">
                            <div class="col-sm-2">
                                <select class="selectpicker m-b-20 m-r-10" id="status" name="status" data-style="form-control">
                                    <option value="">状态</option>
                                    <?php foreach (WxPublic::getStatusMap() as $key => $item): ?>
                                        <option value="<?=$key?>"><?=$item?></option>
                                    <?php endforeach ?>
                                </select>
                            </div>

                            <div class="col-sm-4">
                                <div class="input-group">
                                    <input type="text" class="form-control m-r-5" name="name" value="<?=Yii::$app->request->get('name')?>" placeholder="公众号名称">
                                    <span class="input-group-btn">
                                        <button class="btn btn-info" type="submit">
                                            搜索
                                        </button>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>

                <div class="col-sm-2">
                    <button class="fcbtn btn btn-danger btn-outline btn-1e" onclick="window.location.href='<?=Url::to(['item'])?>'">
                        添加数据
                    </button>
                </div>
            </div>
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>公众号名称</th>
                        <th>累计曝光量</th>
                        <th>昨日曝光量</th>
                        <th>累计关注数</th>
                        <th>昨日关注数</th>
                        <th>终止关注数</th>
                        <th>曝光率</th>
                        <th>状态</th>
                        <th>投禁区域</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($ret as $item): ?>
                    <tr>
                        <td><?=$item["id"]?></td>
                        <td>
                            <?=$item["name"]?>
                        </td>
                        <td><?=$item["total_exposure"]?></td>
                        <td><?=intval($item["eNumber"]["number"])?></td>
                        <td><?=$item["total_follow"]?></td>
                        <td><?=intval($item["fNumber"]["number"])?></td>
                        <td><?=$item["stop_follow_num"]?></td>
                        <td><?=$item["exposure_rate"]?>%</td>

                        <td>
                            <?php if ( $item["status"] == WxPublic::STATUS_YES ) : ?>
                                <span class="label label-rouded label-success"><?=WxPublic::getStatusMap($item["status"])?></span>
                            <?php elseif( $item["status"] == WxPublic::STATUS_NO ) :?>
                                <span class="label label-rouded label-danger"><?=WxPublic::getStatusMap($item["status"])?></span>
                            <?php else :?>
                                <span class="label label-rouded label-warning"><?=WxPublic::getStatusMap($item["status"])?></span>
                            <?php endif ?>
                        </td>
                        <td>
                            <?php $area = $item["area"] ? array_column($item["area"], "city") : [];?>
                            <?=implode(",", $area)?>
                        </td>
                        <td>
                            <a href="<?=Url::to(["item", "id" => $item["id"]])?>" data-toggle="tooltip" data-original-title="编辑"> 编辑 </a>
                            <a rel-title="每日关注数" rel-action="open" href="<?=Url::to(["chart", "id" => $item["id"]])?>" data-toggle="tooltip" data-original-title="图表"> 图表 </a>
                        </td>
                    </tr>
                    <?php endforeach ?>
                    </tbody>
                    <tfoot>
                    <tr>
                        <td colspan="14" class="footable-visible">
                            <div class="text-right">
                                <?=\common\components\DataHelper::getLinkPager($page)?>
                            </div>
                        </td>
                    </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </div>
</div>
<?php $this->endBlock()?>
<?php $this->beginBlock("script")?>
<script>
    autoSelect('status','<?=Yii::$app->request->get('status')?>');
</script>
<?php $this->endBlock(); ?>
